/**
 * @author Luc Yriarte
 * 
 * Licence : BSD http://www.opensource.org/licenses/bsd-license.php
 *  
 */
package neuralNetwork;

import basicSim.Matrix;
import basicSim.Vector;

public class Layer {

	Layer inputLayer;
	UnitFunction transFunc;
	
	public int nCells;
	public Matrix outValue;
	public Vector inWeight[];
	
	public Layer(UnitFunction transFunc, int cells) {
		this.transFunc = transFunc;
		nCells = cells;
		outValue = new Matrix(1,nCells);
		inWeight = null;
		inputLayer = null;
	}
	
	public Layer(UnitFunction transFunc, int cells, Layer inputLayer) {
		this.inputLayer = inputLayer;
		this.transFunc = transFunc;
		nCells = cells;
		outValue = new Matrix(1,nCells);
		inWeight = new Vector[nCells];
		for (int i=0; i<nCells; i++) {
			inWeight[i] = new Vector(inputLayer.nCells);
		}
	}
	
	public void propagate() {
		for (int i=0; i<nCells; i++) {
			outValue.getCell()[0][i] = transFunc.transfer(inputLayer.outValue.mul(inWeight[i]).getCell()[0][0]);
		}
	}
}
